import request from '@/utils/request'
import Qs from 'qs'

export function newsList(query) {
  return request({
    method: 'get',
    params: {
      _gp: 'admin.zhengce',
      _mt: 'list',
      ...query
    }
  })
}

export function detailNews(id) {
  return request({
    method: 'get',
    params: {
      _gp: 'admin.zhengce',
      _mt: 'edit',
      id: id
    }
  })
}

export function deleteNews(id) {
  return request({
    method: 'post',
    params: {
      _gp: 'admin.zhengce',
      _mt: 'delete',
      id: id
    }
  })
}

export function batchDeleteNews(ids) {
  return request({
    method: 'post',
    data: Qs.stringify({
      _gp: 'admin.zhengce',
      _mt: 'batchDelete',
      ids: JSON.stringify(ids)
    })
  })
}

export function editNews(data) {
  return request({
    method: 'post',
    data: Qs.stringify({
      _gp: 'admin.zhengce',
      _mt: 'update',
      newsDO: JSON.stringify(data)
    })
  })
}

export function createNews(data) {
  return request({
    method: 'post',
    data: Qs.stringify({
      _gp: 'admin.zhengce',
      _mt: 'create',
      newsDO: JSON.stringify(data)
    })
  })
}
